<!--
 * @Date: 2023-05-02 16:34:54
 * @LastEditTime: 2023-09-12 17:36:50
 * @FilePath: /wkw/src/views/myTask/index.vue
 * 介绍:
-->
<route lang="json">
{
  "meta": {
    "title": "t('wo-de-reng-wu')"
  }
}
</route>
<script lang="ts" setup>
import { apiMyTaskRatio, ApiMyTaskRatio } from "@@/api/module/userInfo";
import useUserinfoStore from "@@/store/useUserinfoStore";
import { _require } from "@@/utils/tools";
import { fixedDecimals } from "@@/utils/tools/format";
const userinfoStore = useUserinfoStore();
const { userinfo } = storeToRefs(userinfoStore);

const myTaskRatio = ref<ApiMyTaskRatio.Data>();
async function getMyTaskRatio() {
  const res = await apiMyTaskRatio();
  if (!res) return;
  myTaskRatio.value = res;
}
userinfoStore.getUserinfo();
getMyTaskRatio();
</script>
<template>
  <CpageView>
    <Ccard min-height="300rem">
      <div class="T-A-C MT-lg">
        <h3>{{ $t("suo-ding-shu-liang") }}</h3>
        <div class="MT-md">
          <span class="middleText T-strong T-S-xxl">
            {{ fixedDecimals(userinfo?.last_locked) }}
          </span>
          <span class="middleText">WKC</span>
        </div>
      </div>
    </Ccard>
    <div class="MT-xl">
      <Ccard class="MT-md">
        <div class="flex-J-SB flex-A-C T-S-sm">
          <div>
            <span>
              {{ $t("gou-mai") }}
              <span>{{ fixedDecimals(myTaskRatio?.buy_usdt) }}U WKC</span>
            </span>
            <span class="C-warn ML-xs">
              (+{{ fixedDecimals(myTaskRatio?.buy_rate, 0) }}%)
            </span>
          </div>
          <Rbutton
            v-if="!userinfo?.register_task.is_buy"
            @click="$router.replace({ name: 'swap' })"
            bg="var(--C-M1)"
            :size="'small'"
            round
          >
            {{ $t("qu-jiao-yi") }}
          </Rbutton>
          <Rbutton disabled :size="'small'" v-else>
            {{ $t("yi-wan-cheng") }}
          </Rbutton>
        </div>
      </Ccard>
      <Ccard class="MT-md">
        <div class="flex-J-SB flex-A-C T-S-sm">
          <div>
            <span>
              {{ $t("yao-qing-yi-wei-hao-you-bing-gou-mai") }}
              <span> {{ fixedDecimals(myTaskRatio?.buy_usdt) }}U WKC</span>
            </span>
            <span class="C-warn ML-xs">
              (+{{ fixedDecimals(myTaskRatio?.recommend_first, 0) }}%)
            </span>
          </div>
          <Rbutton
            v-if="!(Number(userinfo?.register_task.invite_times) >= 1)"
            @click="$router.push({ name: 'invite' })"
            bg="var(--C-M1)"
            :size="'small'"
            round
          >
            {{ $t("qu-fen-xiang") }}
          </Rbutton>
          <Rbutton disabled :size="'small'" v-else>
            {{ $t("yi-wan-cheng") }}
          </Rbutton>
        </div>
      </Ccard>
      <Ccard class="MT-md">
        <div class="flex-J-SB flex-A-C T-S-sm">
          <div>
            <span>
              {{ $t("zai-yao-qing-yi-wei-hao-you-bing-gou-mai") }}
              <span>{{ fixedDecimals(myTaskRatio?.buy_usdt) }}U WKC </span>
            </span>
            <span class="C-warn ML-xs">
              (+{{ fixedDecimals(myTaskRatio?.recommend_second, 0) }}%)
            </span>
          </div>
          <Rbutton
            v-if="!(Number(userinfo?.register_task.invite_times) >= 2)"
            @click="$router.push({ name: 'invite' })"
            bg="var(--C-warn)"
            :size="'small'"
            round
          >
            {{ $t("qu-fen-xiang") }}
          </Rbutton>
          <Rbutton disabled :size="'small'" v-else>
            {{ $t("yi-wan-cheng") }}
          </Rbutton>
        </div>
      </Ccard>
    </div>
  </CpageView>
</template>
<style lang="scss" scoped>
.middleText {
  vertical-align: middle;
}
</style>
